﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

namespace MvcEnrollment.Helpers
{
    public class RebillPayment
    {
        #region Private Variables
        private string m_ewayCustomerID;
        private string m_CustomerRef;
        private string m_CustomerTitle;
        private string m_CustomerFirstName;
        private string m_CustomerLastName;
        private string m_CustomerCompany;
        private string m_CustomerJobDesc;
        private string m_CustomerEmail;
        private string m_CustomerAddress;
        private string m_CustomerSuburb;
        private string m_CustomerState;
        private string m_CustomerPostCode;
        private string m_CustomerCountry;
        private string m_CustomerPhone1;
        private string m_CustomerPhone2;
        private string m_CustomerFax;
        private string m_CustomerURL;
        private string m_CustomerComments;
        private string m_RebillInvRef;
        private string m_RebillInvDesc;
        private string m_RebillCCname;
        private string m_RebillCCNumber;
        private string m_RebillCCExpMonth;
        private string m_RebillCCExpYear;
        private string m_RebillInitAmt;
        private string m_RebillInitDate;
        private string m_RebillRecurAmt;
        private string m_RebillStartDate;
        private string m_RebillInterval;
        private string m_RebillIntervalType;
        private string m_RebillEndDate;
        private string m_ewayURL;
        #endregion

        #region RebillPayment
        public RebillPayment()
        {
        }
        #endregion

        #region Public Properties
        public string eWAYCustomerID { get { return m_ewayCustomerID; } set { m_ewayCustomerID = value; } }
        public string CustomerRef { get { return m_CustomerRef; } set { m_CustomerRef = value; } }
        public string CustomerTitle { get { return m_CustomerTitle; } set { m_CustomerTitle = value; } }
        public string CustomerFirstName { get { return m_CustomerFirstName; } set { m_CustomerFirstName = value; } }
        public string CustomerLastName { get { return m_CustomerLastName; } set { m_CustomerLastName = value; } }
        public string CustomerCompany { get { return m_CustomerCompany; } set { m_CustomerCompany = value; } }
        public string CustomerJobDesc { get { return m_CustomerJobDesc; } set { m_CustomerJobDesc = value; } }
        public string CustomerEmail { get { return m_CustomerEmail; } set { m_CustomerEmail = value; } }
        public string CustomerAddress { get { return m_CustomerAddress; } set { m_CustomerAddress = value; } }
        public string CustomerSuburb { get { return m_CustomerSuburb; } set { m_CustomerSuburb = value; } }
        public string CustomerState { get { return m_CustomerState; } set { m_CustomerState = value; } }
        public string CustomerPostCode { get { return m_CustomerPostCode; } set { m_CustomerPostCode = value; } }
        public string CustomerCountry { get { return m_CustomerCountry; } set { m_CustomerCountry = value; } }
        public string CustomerPhone1 { get { return m_CustomerPhone1; } set { m_CustomerPhone1 = value; } }
        public string CustomerPhone2 { get { return m_CustomerPhone2; } set { m_CustomerPhone2 = value; } }
        public string CustomerFax { get { return m_CustomerFax; } set { m_CustomerFax = value; } }
        public string CustomerURL { get { return m_CustomerURL; } set { m_CustomerURL = value; } }
        public string CustomerComments { get { return m_CustomerComments; } set { m_CustomerComments = value; } }
        public string RebillInvRef { get { return m_RebillInvRef; } set { m_RebillInvRef = value; } }
        public string RebillInvDesc { get { return m_RebillInvDesc; } set { m_RebillInvDesc = value; } }
        public string RebillCCname { get { return m_RebillCCname; } set { m_RebillCCname = value; } }
        public string RebillCCNumber { get { return m_RebillCCNumber; } set { m_RebillCCNumber = value; } }
        public string RebillCCExpMonth { get { return m_RebillCCExpMonth; } set { m_RebillCCExpMonth = value; } }
        public string RebillCCExpYear { get { return m_RebillCCExpYear; } set { m_RebillCCExpYear = value; } }
        public string RebillInitAmt { get { return m_RebillInitAmt; } set { m_RebillInitAmt = value; } }
        public string RebillInitDate { get { return m_RebillInitDate; } set { m_RebillInitDate = value; } }
        public string RebillRecurAmt { get { return m_RebillRecurAmt; } set { m_RebillRecurAmt = value; } }
        public string RebillStartDate { get { return m_RebillStartDate; } set { m_RebillStartDate = value; } }
        public string RebillInterval { get { return m_RebillInterval; } set { m_RebillInterval = value; } }
        public string RebillIntervalType { get { return m_RebillIntervalType; } set { m_RebillIntervalType = value; } }
        public string RebillEndDate { get { return m_RebillEndDate; } set { m_RebillEndDate = value; } }
        public string ewayURL { get { return m_ewayURL; } set { m_ewayURL = value; } }
        #endregion

        #region Get In XML Format
        public string ToXML()
        {
            XmlDocument xmlRebill = new XmlDocument();
            XmlNode nodeRoot = null;
            XmlNode nodeNewRebill = null;
            XmlNode nodeCustomer = null;
            XmlNode nodeCustomerDetails = null;
            XmlNode nodeRebillEvent = null;
            XmlNode nodeRebillDetails = null;

            nodeRoot = xmlRebill.CreateNode(XmlNodeType.Element, "RebillUpload", "");
            nodeNewRebill = xmlRebill.CreateNode(XmlNodeType.Element, "NewRebill", "");

            nodeCustomer = xmlRebill.CreateNode(XmlNodeType.Element, "eWayCustomerID", "");
            nodeCustomer.InnerText = this.eWAYCustomerID;
            nodeNewRebill.AppendChild(nodeCustomer);

            //Customer 
            nodeCustomer = xmlRebill.CreateNode(XmlNodeType.Element, "Customer", "");

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerRef", "");
            nodeCustomerDetails.InnerText = this.CustomerRef;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerTitle", "");
            nodeCustomerDetails.InnerText = this.CustomerTitle;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerFirstName", "");
            nodeCustomerDetails.InnerText = this.CustomerFirstName;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerLastName", "");
            nodeCustomerDetails.InnerText = this.CustomerLastName;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerCompany", "");
            nodeCustomerDetails.InnerText = this.CustomerCompany;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerJobDesc", "");
            nodeCustomerDetails.InnerText = this.CustomerJobDesc;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerEmail", "");
            nodeCustomerDetails.InnerText = this.CustomerEmail;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerAddress", "");
            nodeCustomerDetails.InnerText = this.CustomerAddress;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerSuburb", "");
            nodeCustomerDetails.InnerText = this.CustomerSuburb;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerState", "");
            nodeCustomerDetails.InnerText = this.CustomerState;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerPostCode", "");
            nodeCustomerDetails.InnerText = this.CustomerPostCode;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerCountry", "");
            nodeCustomerDetails.InnerText = this.CustomerCountry;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerPhone1", "");
            nodeCustomerDetails.InnerText = this.CustomerPhone1;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerPhone2", "");
            nodeCustomerDetails.InnerText = this.CustomerPhone2;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerFax", "");
            nodeCustomerDetails.InnerText = this.CustomerFax;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerURL", "");
            nodeCustomerDetails.InnerText = this.CustomerURL;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeCustomerDetails = xmlRebill.CreateNode(XmlNodeType.Element, "CustomerComments", "");
            nodeCustomerDetails.InnerText = this.CustomerComments;
            nodeCustomer.AppendChild(nodeCustomerDetails);

            nodeNewRebill.AppendChild(nodeCustomer);

            //Rebill Events
            nodeRebillEvent = xmlRebill.CreateNode(XmlNodeType.Element, "RebillEvent", "");

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillInvRef", "");
            nodeRebillDetails.InnerText = this.RebillInvRef;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillInvDesc", "");
            nodeRebillDetails.InnerText = this.RebillInvDesc;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillCCName", "");
            nodeRebillDetails.InnerText = this.RebillCCname;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillCCNumber", "");
            nodeRebillDetails.InnerText = this.RebillCCNumber;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillCCExpMonth", "");
            nodeRebillDetails.InnerText = this.RebillCCExpMonth;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillCCExpYear", "");
            nodeRebillDetails.InnerText = this.RebillCCExpYear;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillInitAmt", "");
            nodeRebillDetails.InnerText = this.RebillInitAmt;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillInitDate", "");
            nodeRebillDetails.InnerText = this.RebillInitDate;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillRecurAmt", "");
            nodeRebillDetails.InnerText = this.RebillRecurAmt;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillStartDate", "");
            nodeRebillDetails.InnerText = this.RebillStartDate;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillInterval", "");
            nodeRebillDetails.InnerText = this.RebillInterval;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillIntervalType", "");
            nodeRebillDetails.InnerText = this.RebillIntervalType;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeRebillDetails = xmlRebill.CreateNode(XmlNodeType.Element, "RebillEndDate", "");
            nodeRebillDetails.InnerText = this.RebillEndDate;
            nodeRebillEvent.AppendChild(nodeRebillDetails);

            nodeNewRebill.AppendChild(nodeRebillEvent);

            nodeRoot.AppendChild(nodeNewRebill);

            xmlRebill.AppendChild(nodeRoot);

            return xmlRebill.InnerXml;

        }
        #endregion
    }
}